import { notification } from "ant-design-vue";
import router from "@/router/index";
import { useAuthStore } from "@/stores";

export const loginOut = () => {
  const { setUserInfo } = useAuthStore();
  // Notification.warning({
  //   title: "提示",
  //   content: "权限不足",
  // });
  setUserInfo({});
  sessionStorage.clear();
  router.push("/login");
  console.log("用户退出");
};

export const verifyAuth = () => {
  const { userInfo } = useAuthStore();

  if (userInfo.name) return;

  notification.warn({
    message: "提示",
    description: "无权访问！",
  });

  setTimeout(() => {
    sessionStorage.clear();
    router.push("/login");
  }, 500);
};
